Logo
Spacer News Wiki Features F.A.Q. Team members Screenshots Download Messageboard Bug tracker Submit files
Top divider

Lua UnitDefs

The UnitDefs[] table holds all information about the units used in the mod. Note: Its entries are metatables, so you can't use the pairs() iterator on them, use this instead:

 for id,unitDef in pairs(UnitDefs) do
   for name,param in unitDef:pairs() do
     Spring.Echo(name,param)
   end
 end

Very usefull is UnitDefs[i]["customParams"], since you can access any custom fbi param with it and use it in your lua scripts.

So because the UnitDefs tables are very large, I simple print here an example of it (BA5.8 core commander):

 UnitDefs[216]["customParams"] = {
   }
 UnitDefs[216]["TEDClass"] = "COMMANDER",
 UnitDefs[216]["activateWhenBuilt"] = true,
 UnitDefs[216]["aihint"] = 216,
 UnitDefs[216]["cobID"] = -1,
 UnitDefs[216]["airLosRadius"] = 21.09375,
 UnitDefs[216]["airStrafe"] = true,
 UnitDefs[216]["armorType"] = 8,
 UnitDefs[216]["armoredMultiple"] = 1,
 UnitDefs[216]["autoHeal"] = 2.6666667461395,
 UnitDefs[216]["buildDistance"] = 128,
 UnitDefs[216]["buildOptions"] = {
     [1] = unitDefID1,
     [2] = unitDefID2,
     ...
   }
 UnitDefs[216]["buildRange3D"] = true,
 UnitDefs[216]["buildSpeed"] = 300,
 UnitDefs[216]["buildTime"] = 75000,
 UnitDefs[216]["buildangle"] = 0,
 UnitDefs[216]["builder"] = true,
 UnitDefs[216]["buildingDecalDecaySpeed"] = 0.10000000149012,
 UnitDefs[216]["buildingDecalSizeX"] = 4,
 UnitDefs[216]["buildingDecalSizeY"] = 4,
 UnitDefs[216]["buildingDecalType"] = 0,
 UnitDefs[216]["buildpicname"] = "CORCOM.DDS",
 UnitDefs[216]["canAssist"] = true,
 UnitDefs[216]["canAttack"] = true,
 UnitDefs[216]["canBeAssisted"] = true,
 UnitDefs[216]["canBuild"] = true,
 UnitDefs[216]["canCapture"] = true,
 UnitDefs[216]["canCloak"] = true,
 UnitDefs[216]["canDGun"] = true,
 UnitDefs[216]["canDropFlare"] = false,
 UnitDefs[216]["canFight"] = true,
 UnitDefs[216]["canFly"] = false,
 UnitDefs[216]["canGuard"] = true,
 UnitDefs[216]["canHover"] = false,
 UnitDefs[216]["canKamikaze"] = false,
 UnitDefs[216]["canLoopbackAttack"] = false,
 UnitDefs[216]["canMove"] = true,
 UnitDefs[216]["canPatrol"] = true,
 UnitDefs[216]["canReclaim"] = true,
 UnitDefs[216]["canRepair"] = true,
 UnitDefs[216]["canRepeat"] = true,
 UnitDefs[216]["canRestore"] = true,
 UnitDefs[216]["canResurrect"] = false,
 UnitDefs[216]["canSelfRepair"] = false,
 UnitDefs[216]["canSubmerge"] = false,
 UnitDefs[216]["capturable"] = false,
 UnitDefs[216]["captureSpeed"] = 300,
 UnitDefs[216]["cloakCost"] = 100,
 UnitDefs[216]["cloakCostMoving"] = 1000,
 UnitDefs[216]["controlRadius"] = 32,
 UnitDefs[216]["deathExplosion"] = "COMMANDER_BLAST",
 UnitDefs[216]["decloakDistance"] = 50,
 UnitDefs[216]["decloakOnFire"] = true,
 UnitDefs[216]["decloakSpherical"] = true,
 UnitDefs[216]["decoyDef"] = nil, 
 UnitDefs[216]["dlHoverFactor"] = -1,
 UnitDefs[216]["drag"] = 0.13046109676361,
 UnitDefs[216]["energyCost"] = 2500,
 UnitDefs[216]["energyMake"] = 25,
 UnitDefs[216]["energyStorage"] = 0,
 UnitDefs[216]["energyUpkeep"] = 0,
 UnitDefs[216]["extractRange"] = 0,
 UnitDefs[216]["extractsMetal"] = 0,
 UnitDefs[216]["factoryHeadingTakeoff"] = false,
 UnitDefs[216]["fallSpeed"] = 1,
 UnitDefs[216]["filename"] = "units/corcom.fbi",
 UnitDefs[216]["flankingBonusMode"] = 0,
 UnitDefs[216]["flankingBonusMax"] = 0,
 UnitDefs[216]["flankingBonusMin"] = 0,
 UnitDefs[216]["flankingBonusDirX"] = 0,
 UnitDefs[216]["flankingBonusDirY"] = 0,
 UnitDefs[216]["flankingBonusDirZ"] = 0,
 UnitDefs[216]["flankingBonusMobilityAdd"] = 0,
 UnitDefs[216]["flareDelay"] = 0.30000001192093,
 UnitDefs[216]["flareDropVectorX"] = 0,
 UnitDefs[216]["flareDropVectorY"] = 0,
 UnitDefs[216]["flareDropVectorZ"] = 0,
 UnitDefs[216]["flareEfficiency"] = 0.5,
 UnitDefs[216]["flareReloadTime"] = 5,
 UnitDefs[216]["flareSalvoDelay"] = 0,
 UnitDefs[216]["flareSalvoSize"] = 4,
 UnitDefs[216]["flareTime"] = 90,
 UnitDefs[216]["floater"] = false,
 UnitDefs[216]["frontToSpeed"] = 0.10000000149012,
 UnitDefs[216]["fullHealthFactory"] = false,
 UnitDefs[216]["gaia"] = "",
 UnitDefs[216]["health"] = 3000,
 UnitDefs[216]["height"] = 42.333557128906,
 UnitDefs[216]["hideDamage"] = true,
 UnitDefs[216]["highTrajectoryType"] = 0,
 UnitDefs[216]["hitSphereOffsetX"] = 0,
 UnitDefs[216]["hitSphereOffsetY"] = 0,
 UnitDefs[216]["hitSphereOffsetZ"] = 0,
 UnitDefs[216]["hitSphereScale"] = 1,
 UnitDefs[216]["holdSteady"] = true,
 UnitDefs[216]["hoverAttack"] = false,
 UnitDefs[216]["humanName"] = "Commander",
 UnitDefs[216]["iconType"] = "corcommander",
 UnitDefs[216]["id"] = 216,
 UnitDefs[216]["idleAutoHeal"] = 2.6666667461395,
 UnitDefs[216]["idleTime"] = 1800,
 UnitDefs[216]["isAirBase"] = false,
 UnitDefs[216]["isBomber"] = false,
 UnitDefs[216]["isBuilder"] = true,
 UnitDefs[216]["isBuilding"] = false,
 UnitDefs[216]["isCommander"] = true,
 UnitDefs[216]["isFactory"] = false,
 UnitDefs[216]["isFeature"] = false,
 UnitDefs[216]["isFighter"] = false,
 UnitDefs[216]["isFirePlatform"] = false,
 UnitDefs[216]["isGroundUnit"] = false,
 UnitDefs[216]["isMetalExtractor"] = false,
 UnitDefs[216]["isMetalMaker"] = false,
 UnitDefs[216]["isTransport"] = false,
 UnitDefs[216]["jammerRadius"] = 0,
 UnitDefs[216]["kamikazeDist"] = 0,
 UnitDefs[216]["leaveTracks"] = false,
 UnitDefs[216]["levelGround"] = true,
 UnitDefs[216]["loadingRadius"] = 220,
 UnitDefs[216]["losHeight"] = 20,
 UnitDefs[216]["losRadius"] = 28.125,
 UnitDefs[216]["makesMetal"] = 0,
 UnitDefs[216]["mass"] = 5000,
 UnitDefs[216]["maxAcc"] = 0.18000000715256,
 UnitDefs[216]["maxAileron"] = 0.014999999664724,
 UnitDefs[216]["maxBank"] = 0.80000001192093,
 UnitDefs[216]["maxDec"] = 0.037500001490116,
 UnitDefs[216]["maxElevator"] = 0.0099999997764826,
 UnitDefs[216]["maxFuel"] = 0,
 UnitDefs[216]["maxHeightDif"] = 14.558809280396,
 UnitDefs[216]["maxPitch"] = 0.44999998807907,
 UnitDefs[216]["maxRepairSpeed"] = 300,
 UnitDefs[216]["maxRudder"] = 0.0040000001899898,
 UnitDefs[216]["maxSlope"] = 0.93969261646271,
 UnitDefs[216]["maxThisUnit"] = 5000,
 UnitDefs[216]["maxWaterDepth"] = 35,
 UnitDefs[216]["maxWeaponRange"] = 300,
 UnitDefs[216]["maxx"] = 17.456253051758,
 UnitDefs[216]["maxy"] = 42.333557128906,
 UnitDefs[216]["maxz"] = 22.837493896484,
 UnitDefs[216]["metalCost"] = 2500,
 UnitDefs[216]["metalMake"] = 1.5,
 UnitDefs[216]["metalStorage"] = 0,
 UnitDefs[216]["metalUpkeep"] = 0,
 UnitDefs[216]["midx"] = 0,
 UnitDefs[216]["midy"] = 19.558204650879,
 UnitDefs[216]["midz"] = 0,
 UnitDefs[216]["minAirBasePower"] = 0,
 UnitDefs[216]["minCollisionSpeed"] = 1,
 UnitDefs[216]["minWaterDepth"] = -10000000,
 UnitDefs[216]["minx"] = -17.456253051758,
 UnitDefs[216]["miny"] = -3.2171478271484,
 UnitDefs[216]["minz"] = -9.9750061035156,
 UnitDefs[216]["modCategories"] = {
     ["notship"] = false,
     ["notair"] = false,
     ["core"] = false,
     ["commander"] = false,
     ["all"] = false,
     ["level10"] = false,
     ["ctrl_c"] = false,
     ["notsub"] = false,
     ["weapon"] = false,
   }
 UnitDefs[216]["model"] = {
     ["textures"] = {
     }
     ["type"] = "3do",
     ["name"] = "CORCOM",
     ["path"] = "objects3d/CORCOM",
   }
 UnitDefs[216]["moveData"] = {
     ["name"] = "KBOT3",
     ["type"] = "ground",
     ["maxSlope"] = 0.41221475601196,
     ["id"] = 2,
     ["depthMod"] = 0.10000000149012,
     ["crushStrength"] = 50,
     ["family"] = "kbot",
     ["depth"] = 5000,
     ["slopeMod"] = 9.680196762085,
     ["size"] = 4,
   }
 UnitDefs[216]["moveType"] = 0,
 UnitDefs[216]["myGravity"] = 0.40000000596046,
 UnitDefs[216]["name"] = "corcom",
 UnitDefs[216]["nanoColorB"] = 0.20000000298023,
 UnitDefs[216]["nanoColorG"] = 0.69999998807907,
 UnitDefs[216]["nanoColorR"] = 0.20000000298023,
 UnitDefs[216]["needGeo"] = false,
 UnitDefs[216]["noAutoFire"] = false,
 UnitDefs[216]["noChaseCategories"] = {
     ["all"] = false,
   }
 UnitDefs[216]["onOffable"] = false,
 UnitDefs[216]["pieceTrailCEGTag"] = "",
 UnitDefs[216]["pieceTrailCEGRange"] = 0,
 UnitDefs[216]["power"] = 2541.6667480469,
 UnitDefs[216]["radarRadius"] = 700,
 UnitDefs[216]["radius"] = 24.740692138672,
 UnitDefs[216]["reclaimSpeed"] = 300,
 UnitDefs[216]["reclaimable"] = false,
 UnitDefs[216]["refuelTime"] = 5,
 UnitDefs[216]["releaseHeld"] = false,
 UnitDefs[216]["repairSpeed"] = 300,
 UnitDefs[216]["resurrectSpeed"] = 300,
 UnitDefs[216]["seismicRadius"] = 0,
 UnitDefs[216]["seismicSignature"] = 0,
 UnitDefs[216]["selfDCountdown"] = 5,
 UnitDefs[216]["selfDExplosion"] = "COMMANDER_BLAST",
 UnitDefs[216]["shieldWeaponDef"] = nil, 
 UnitDefs[216]["showNanoFrame"] = true,
 UnitDefs[216]["showNanoSpray"] = true,
 UnitDefs[216]["showPlayerName"] = true,
 UnitDefs[216]["slideTolerance"] = 0,
 UnitDefs[216]["smoothAnim"] = true,
 UnitDefs[216]["sonarJamRadius"] = 0,
 UnitDefs[216]["sonarRadius"] = 300,
 UnitDefs[216]["sounds"] = {
     ["repair"] = {
     }
     ["arrived"] = {
     }
     ["underattack"] = {
       [1] = {
         ["id"] = 140,
         ["name"] = "warning2",
         ["volume"] = 5,
       }
     }
     ["select"] = {
       [1] = {
         ["id"] = 213,
         ["name"] = "kccorsel",
         ["volume"] = 5,
       }
     }
     ["deactivate"] = {
     }
     ["activate"] = {
     }
     ["ok"] = {
       [1] = {
         ["id"] = 212,
         ["name"] = "kcormov",
         ["volume"] = 5,
       }
     }
     ["cant"] = {
       [1] = {
         ["id"] = 92,
         ["name"] = "cantdo4",
         ["volume"] = 5,
       }
     }
     ["working"] = {
     }
     ["build"] = {
       [1] = {
         ["id"] = 197,
         ["name"] = "nanlath2",
         ["volume"] = 5,
       }
     }
   }
 UnitDefs[216]["speed"] = 37.5,
 UnitDefs[216]["speedToFront"] = 0.070000000298023,
 UnitDefs[216]["springCategories"] = {
     ["commander"] = false,
     ["notship"] = false,
     ["notair"] = false,
     ["all"] = false,
     ["notsub"] = false,
     ["weapon"] = false,
   }
 UnitDefs[216]["startCloaked"] = false,
 UnitDefs[216]["stealth"] = false,
 UnitDefs[216]["stockpileWeaponDef"] = nil, 
 UnitDefs[216]["targfac"] = false,
 UnitDefs[216]["techLevel"] = 0,
 UnitDefs[216]["terraformSpeed"] = 300,
 UnitDefs[216]["tidalGenerator"] = 0,
 UnitDefs[216]["tooltip"] = "Commander",
 UnitDefs[216]["totalEnergyOut"] = 25,
 UnitDefs[216]["trackOffset"] = 0,
 UnitDefs[216]["trackStrength"] = 0,
 UnitDefs[216]["trackStretch"] = 1,
 UnitDefs[216]["trackType"] = 0,
 UnitDefs[216]["trackWidth"] = 32,
 UnitDefs[216]["transportByEnemy"] = true,
 UnitDefs[216]["transportCapacity"] = 0,
 UnitDefs[216]["transportMass"] = 100000,
 UnitDefs[216]["transportSize"] = 0,
 UnitDefs[216]["transportUnloadMethod"] = 0,
 UnitDefs[216]["turnRadius"] = 500,
 UnitDefs[216]["turnRate"] = 1133,
 UnitDefs[216]["type"] = "Builder",
 UnitDefs[216]["unitFallSpeed"] = 1.0,
 UnitDefs[216]["upright"] = true,
 UnitDefs[216]["useBuildingGroundDecal"] = false,
 UnitDefs[216]["useHitSphereOffset"] = false,
 UnitDefs[216]["wantedHeight"] = 0,
 UnitDefs[216]["waterline"] = 0,
 UnitDefs[216]["weapons"] = {
     [1] = {
       ["onlyTargets"] = {
         ["antiflame"] = false,
         ["vtol"] = false,
         ["notland"] = false,
         ["fort"] = false,
         ["special"] = false,
         ["notair"] = false,
         ["kbot"] = false,
         ["antiemg"] = false,
         ["commander"] = false,
         ["jam"] = false,
         ["tport"] = false,
         ["constr"] = false,
         ["strategic"] = false,
         ["kamikaze"] = false,
         ["minelayer"] = false,
         ["hover"] = false,
         ["noweapon"] = false,
         ["plant"] = false,
         ["ship"] = false,
         ["antilaser"] = false,
         ["phib"] = false,
         ["mine"] = false,
         ["notstructure"] = false,
         ["tank"] = false,
         ["mobile"] = false,
         ["underwater"] = false,
         ["antigator"] = false,
         ["notship"] = false,
         ["all"] = false,
         ["notsub"] = false,
         ["weapon"] = false,
       }
       ["weaponDef"] = 39,
       ["slavedTo"] = 0,
       ["badTargets"] = {
         ["antilaser"] = false,
       }
       ["fuelUsage"] = 0,
       ["mainDirX"]  = 0,
       ["mainDirY"]  = 0,
       ["mainDirZ"]  = 1,
       ["maxAngleDif"] = -1,
     }
     [2] = {
       ["onlyTargets"] = {
       }
       ["weaponDef"] = 195,
       ["slavedTo"] = 0,
       ["badTargets"] = {
       }
       ["fuelUsage"] = 0,
       ["maxAngleDif"] = -1,
     }
     [3] = {
       ["onlyTargets"] = {
         ["antiflame"] = false,
         ["vtol"] = false,
         ["notland"] = false,
         ["fort"] = false,
         ["special"] = false,
         ["notair"] = false,
         ["kbot"] = false,
         ["antiemg"] = false,
         ["commander"] = false,
         ["jam"] = false,
         ["tport"] = false,
         ["constr"] = false,
         ["strategic"] = false,
         ["kamikaze"] = false,
         ["minelayer"] = false,
         ["hover"] = false,
         ["noweapon"] = false,
         ["plant"] = false,
         ["ship"] = false,
         ["antilaser"] = false,
         ["phib"] = false,
         ["mine"] = false,
         ["notstructure"] = false,
         ["tank"] = false,
         ["mobile"] = false,
         ["underwater"] = false,
         ["antigator"] = false,
         ["notship"] = false,
         ["all"] = false,
         ["notsub"] = false,
         ["weapon"] = false,
       }
       ["weaponDef"] = 13,
       ["slavedTo"] = 0,
       ["badTargets"] = {
       }
       ["fuelUsage"] = 0,
       ["maxAngleDif"] = -1,
     }
   }
 UnitDefs[216]["windGenerator"] = 0,
 UnitDefs[216]["wingAngle"] = 0.079999998211861,
 UnitDefs[216]["wingDrag"] = 0.070000000298023,
 UnitDefs[216]["wreckName"] = "CORCOM_DEAD",
 UnitDefs[216]["xsize"] = 4,
 UnitDefs[216]["ysize"] = 4,
 UnitDefs[216]["canParalyze"] = false,
 UnitDefs[216]["canStockpile"] = false,
 UnitDefs[216]["hasShield"] = false,
 UnitDefs[216]["canAttackWater"] = false,
 UnitDefs[216]["cost"] = 2541.6667480469,

Retrieved from "http://spring.clan-sy.com/wiki/Lua_UnitDefs"

This page has been accessed 603 times. This page was last modified 18:28, 18 January 2008.